const userModel=require('../models/model/model')
module.exports={
    index(req,res){
        res.render('admin/index/index.html')
    },
    logout(req,res){
        //用户退出 清空session 
        req.session.username=null
        delete  req.session.username   //删除用户信息
        //返回登录页面
        res.redirect('/admin/login')
    },
    //添加用户页面
    async index_v1(req,res){
        let List=await userModel.userList(req.body)
        console.log(List)
        res.render('admin/index/index_v1.html',{List})
    },
    index_v2(req,res){
        res.render('admin/index/index_v2.html')
    },
    index_add(req,res){
        userModel.model.insertMany({
        username:req.body.username,
        password:req.body.password,
        username:req.body.nickname,
        password:req.body.email,
        }).then((err)=>{
        console.log(err)})
        res.send('添加成功')
        },
    
    // async list(req,res){
    //    let data=  await  userModel.model.find({},{__v:0},)
    //    console.log(data)
    //     res.render('admin/home/list.html',data)
    // },     
}



